
#ifndef _CAN_RINGBUFF_H_
#define _CAN_RINGBUFF_H_


#include "stdint.h"
#include "gd32f30x_can.h"

#define CAN_MSG_BUFFER_LENGTH      32


typedef enum
{
	ID_STANDARD = 0,
	ID_EXTENDED = 1

}ENUM_CAN_ID_TYPE;


typedef enum
{
	FRAME_DATA = 0,
	FRAME_REMOTE = 1

}ENUM_CAN_FRAME_TYPE;


typedef struct
{
	uint32_t ID;
	
	ENUM_CAN_ID_TYPE     ID_type;
	ENUM_CAN_FRAME_TYPE  frame_type;
	
	uint8_t  length;
	uint8_t  data[8];

}STR_CAN_MESSAGE;


typedef struct
{
	char* buff_name;
	
	STR_CAN_MESSAGE  msg[CAN_MSG_BUFFER_LENGTH];
	
	uint16_t length;
	uint16_t read_index;
	uint16_t write_index;
	uint16_t full_flg;
	
	uint16_t reading_flg;
	uint16_t writing_flg;

}STR_CAN_BUFFER;





extern int16_t can_ringbuf_read(STR_CAN_BUFFER* packetbuf, STR_CAN_MESSAGE* temp);
extern int16_t can_ringbuf_write(STR_CAN_BUFFER* packetbuf, STR_CAN_MESSAGE* temp);





#endif














